﻿////BUT: it also seems to run forever until you may see the result

//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Drawing;
//using System.Drawing.Imaging;

//namespace LowLevelGraphics.Filter
//{
//    /// <summary>
//    /// 
//    /// </summary>
//    public class LinesExperimental : BaseImageFilter
//    {
//        protected int nR = 20;
//        protected int nG = 20;
//        protected int nB = 20;

//        /// <summary>
//        /// Initializes a new instance of the <see cref="LinesExperimental"/> class.
//        /// </summary>
//        public LinesExperimental()
//            : this(20,20,20)
//        {
//        }

//        /// <summary>
//        /// Gets or sets the R.
//        /// </summary>
//        /// <value>The R.</value>
//        public int R
//        {
//            get { return nR; }
//            set { nR = value; }
//        }

//        /// <summary>
//        /// Gets or sets the G.
//        /// </summary>
//        /// <value>The G.</value>
//        public int G
//        {
//            get { return nG; }
//            set { nG = value; }
//        }

//        /// <summary>
//        /// Gets or sets the B.
//        /// </summary>
//        /// <value>The B.</value>
//        public int B
//        {
//            get { return nB; }
//            set { nB = value; }
//        }

//        /// <summary>
//        /// Initializes a new instance of the <see cref="LinesExperimental"/> class.
//        /// </summary>
//        /// <param name="_nR">The _n R.</param>
//        /// <param name="_nG">The _n G.</param>
//        /// <param name="_nB">The _n B.</param>
//        public LinesExperimental(int _nR, int _nG, int _nB)
//        {
//            nR = _nR;
//            nG = _nG;
//            nB = _nB;
//        }

//        /// <summary>
//        /// Execute this Filter
//        /// A Debug Statement is written if a concrete Filter is called
//        /// </summary>
//        /// <param name="_bitmap"></param>
//        /// <returns></returns>
//        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
//        {
//            //Bitmap bitmap = _bitmap;
//            UnsafeBitmap bitmap = _bitmap;

//            Color[] aColor = new Color[3];
//            List<Point> aPoint = new List<Point>();

//            int x = 0; int y = 0;

//            int nUnneededOperation = 0;

//            int nHeight = _bitmap.Height;
//            int nWidth = _bitmap.Width;

//            Color color1stRow = Color.Transparent;
//            Color color2nd = Color.Transparent;

//            for (x = 1; x < nWidth - 1; x++)
//            {
//                for (y = 1; y < nHeight - 1; y++)
//                {
//                    aColor[0] = bitmap.GetPixel(x - 1, y + 1);
//                    aColor[1] = bitmap.GetPixel(x, y + 1);
//                    color1stRow = bitmap.GetPixel(x, y);
//                    for (int i = -1; i <= 0; i++)
//                    {
//                        color2nd = aColor[i + 1];
//                        if (ColorFunctions.IsInColorTolerance(color1stRow, color2nd, nR, nG, nB))
//                        {
//                            Point ptPoint = new Point(x + i, y + i);
//                            if (!aPoint.Contains(ptPoint))
//                            {
//                                aPoint.Add(ptPoint);
//                            }
//                            //Use this only to debug
//                            //TODO: if we no more come here, the routine is successfully optimized
//                            else
//                            {
//                                nUnneededOperation++;
//                            }
//                        }
//                    }
//                }
//            }

//            Graphics graphics = Graphics.FromImage(_bitmap.InternalBitmap);
//            graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, _bitmap.Width, _bitmap.Height);

//            //Optimize
//            for (int i = 0; i < aPoint.Count; i++)
//            {
//                _bitmap.SetPixel(aPoint[i].X, aPoint[i].Y, Color.White);
//            }

//            return _bitmap;
//        }

//        /// <summary>
//        /// This is used to clone a filter, each filter must implement it's own clone functionality
//        /// </summary>
//        /// <returns></returns>
//        public override object Clone()
//        {
//            return new LinesExperimental(this.nR, this.nG, this.nB);
//        }
//    }
//}
